package com.zzedu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzedu.common.utils.StringUtils;
import com.zzedu.domain.ZzThesaurusAttr;
import com.zzedu.dto.ZzThesaurusAttrDTO;
import com.zzedu.mapper.ZzThesaurusAttrMapper;
import com.zzedu.service.IZzThesaurusAttrService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 单词属性Service业务层处理
 * 
 * @author Mr.Wang
 * @date 2025-01-29
 */
@Service
public class ZzThesaurusAttrServiceImpl extends ServiceImpl<ZzThesaurusAttrMapper,ZzThesaurusAttr> implements IZzThesaurusAttrService
{

    @Override
    public LambdaQueryWrapper<ZzThesaurusAttr> buildQuery(ZzThesaurusAttrDTO zzThesaurusAttr) {
        LambdaQueryWrapper<ZzThesaurusAttr> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(null!=zzThesaurusAttr.getWordId(), ZzThesaurusAttr::getWordId, zzThesaurusAttr.getWordId());
        lambdaQueryWrapper.like(StringUtils.isNotBlank(zzThesaurusAttr.getAttrName()), ZzThesaurusAttr::getAttrName, zzThesaurusAttr.getAttrName());
        lambdaQueryWrapper.eq(StringUtils.isNotBlank(zzThesaurusAttr.getAttrCode()), ZzThesaurusAttr::getAttrCode, zzThesaurusAttr.getAttrCode());
        lambdaQueryWrapper.eq(StringUtils.isNotBlank(zzThesaurusAttr.getAttrValue()), ZzThesaurusAttr::getAttrValue, zzThesaurusAttr.getAttrValue());
        lambdaQueryWrapper.eq(null!=zzThesaurusAttr.getGmtCreate(), ZzThesaurusAttr::getGmtCreate, zzThesaurusAttr.getGmtCreate());
        lambdaQueryWrapper.eq(null!=zzThesaurusAttr.getGmtModify(), ZzThesaurusAttr::getGmtModify, zzThesaurusAttr.getGmtModify());
        lambdaQueryWrapper.eq(null!=zzThesaurusAttr.getDeleted(), ZzThesaurusAttr::getDeleted, zzThesaurusAttr.getDeleted());

        lambdaQueryWrapper.orderByDesc(ZzThesaurusAttr::getId);
        return lambdaQueryWrapper;
    }
    @Override
    public List<ZzThesaurusAttr> getByWordIdAndAttrOne(List<Long> wordsId, List<String> attrCodeList) {
        return baseMapper.getByWordIdAndAttrOne(wordsId,attrCodeList);
    }
}